package project.sample.nio.channel.filechannel;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @author: WUZH009
 * @date: 2019/8/16 16:11
 **/
public class TestFileChannel2 {
    public static void main(String[] args) {
        try(FileChannel fc = new FileInputStream(new File("d:/1.txt")).getChannel()){
            ByteBuffer buffer = ByteBuffer.allocate((int) fc.size());
            fc.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
